

///////////////////////////////////////
/// ADD WIMMER AND FEINSTEIN NATIONALIST MOBIL. DATA
/// Carl MC, 17.8.2021
///////////////////////////////////////

cd $HOMEDIR
// Load Wimmer and Feinstein Data in main directory
use "../WimmerFeinsteinReplication.dta", clear

// Gen new ID
gen mwid = cowcode

// Keep only very few variables
keep mwid year literacy natorgyesno natorglag

// Save as tempfile
tempfile wimfein
save `wimfein'


// Load analysis data

cd $OUTDIR

use analysis_data, clear

// Encode Wimmer and Feinstein ID
gen mwid = id

// Correct Germany
replace mwid = 255  if mwid == 240
replace mwid = 255  if mwid == 245
replace mwid = 255  if mwid == 260
replace mwid = 255  if mwid == 265
replace mwid = 255  if mwid == 267
replace mwid = 255  if mwid == 269
replace mwid = 255  if mwid == 271
replace mwid = 255  if mwid == 273
replace mwid = 255  if mwid == 275
replace mwid = 255  if mwid == 280
replace mwid = 255  if mwid > 10000 & mwid < 10045

// Italy
replace mwid = 325  if mwid == 10027
replace mwid = 325  if mwid == 327
replace mwid = 325  if mwid == 332
replace mwid = 325  if mwid == 335
replace mwid = 325  if mwid == 10354

// Austria, others
replace mwid = 305  if mwid == 300
replace mwid = 316  if mwid == 315
replace mwid = 345  if mwid == 340
replace mwid = 345  if mwid == 341
replace mwid = 345  if mwid == 347


// Merge
merge m:1 mwid year using `wimfein'
drop if _merge == 2
drop _merge

// Save
save analysis_data, replace
